<?php

if ( ! session_id() ) {
	session_start();
}

if ( isset($_SESSION['user']) ) {
	$user=$_SESSION['user'];
	
	if ( isset($_POST['logout']) ) {
		unset($_POST['logout']);
		session_unset();
		session_destroy();
		header( 'Location: index.php' );
		exit;
	}
	display();
}
exit;

// All functions below this point

// Display page content
function display() {
	giveHeader();
	giveBody();
}

function giveHeader() {

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
?>

<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--
	* File Name:  home.php
	* Author: Arthur Brown SID: 6335497
	* Date Written: 21/10/2009 12:00
	* Version: 1.0
	* Last Modified: 
	* Description: PHP Assignment
-->

<head>
<title>Other Page</title>
</head>
<body>

<?php
} // end of giveHeader function

function giveBody() {

?>
<h1> Welcome 
	<?php 
	global $user;
	if ("$user") { echo " " .ucwords($user); } ?> 
to Arthur's Other page.</h1>
<b>The Other_page Time is: 
	<?php echo date("H:i (Y-m-d)"); ?>
</b><br /> 
	<?php
		echo "<br /><br />";
		echo "<form name=\"logout\" method=\"post\" action=\"index.php\">";
		echo "<input type=\"submit\" value=\"Home\">";
		echo "</form>";
		?>
</body>
</html>
<?php
} // end of giveBody function
?>

